package com.potenza.training.interview.controller;

import com.potenza.training.interview.entity.InterviewResultEntity;
import com.potenza.training.interview.service.InterviewResultService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-08-01 16:03:42
 */
@RestController
@RequestMapping("interview/interviewresult")
public class InterviewResultController {
    @Autowired
    private InterviewResultService interviewResultService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("resume:interviewresult:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = interviewResultService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("resume:interviewresult:info")
    public R info(@PathVariable("id") Long id){
		InterviewResultEntity interviewResult = interviewResultService.getById(id);

        return R.ok().put("interviewResult", interviewResult);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("resume:interviewresult:save")
    public R save(@RequestBody InterviewResultEntity interviewResult){
		interviewResultService.save(interviewResult);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("resume:interviewresult:update")
    public R update(@RequestBody InterviewResultEntity interviewResult){
		interviewResultService.updateById(interviewResult);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("resume:interviewresult:delete")
    public R delete(@RequestBody Long[] ids){
		interviewResultService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 回显
     */
    @RequestMapping("/findByInvitationId/{id}")
    @RequiresPermissions("resume:interviewresult:findByInvitationId")
    public R findByInvitationId(@PathVariable Integer id){
        InterviewResultEntity interviewResultEntity = interviewResultService.findByInvitationId(id);

        return R.ok().put("findByInvitationId",interviewResultEntity);
    }
}
